<template>
	<view style="padding-bottom:50rpx;">
		<page-head :title="'钱包明细'" :headtype="2"></page-head>
		<view class="tagnav">
			<view class="tagnavmain marginAuto">
				<view class="naveach" @click="navfun(1)" :class="navac == 1 ? 'navactive':''">收益
					<view class="naveachx"></view>
				</view>
				<view class="naveach" @click="navfun(2)" :class="navac == 2 ? 'navactive':''">支出
					<view class="naveachx"></view>
				</view>
			</view>
		</view>
		<view class="mx marginAuto">
			<view class="mxeach flex" v-for="(item,index) in datas" :key="index">
				<view class="mxeachl">
					<view class="mxeachlt flex">
						<view>{{ item.title }}</view>
						<!-- <view class="mainColor" style="margin-left:10rpx;" v-if="navac == 1">昵称</view>
						<view class="mainColor" style="margin-left:10rpx;" v-if="navac == 1">购买</view> -->
					</view>
					<view class="mxeachltime">{{ item.create_time }}</view>
				</view>
				<view class="mxeachr flex">
					<text style="font-size:50rpx;" v-if="navac == 1">+</text>
					<text style="font-size:50rpx;" v-if="navac == 2">-</text>
					<text style="font-size:24rpx;">￥</text>
					<text style="font-size:40rpx;">{{ item.amount }}</text>
					<text class="withstatus mainColor" v-if="navac == 2">支出成功</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				apifun:this.apifun,
				page:1,
				navac:1,
				datas:[]
			};
		},
		onLoad() {
			this.initData()
		},
		methods: {
			initData(){
				let sendData = {
					page:this.page,
					limit:this.apifun.limit,
					type:this.navac-1
				}
				this.apifun.unirequest('/api/user/getMoneyDetail','post',sendData,(res)=>{
					if(res.code === 200){
						let datas = res.data;
						if(datas.data.length <= 0){
							this.page--;
							return false
						};
						this.datas = [...this.datas,...datas.data];
					}else{
						this.apifun.toast(res.msg)
					}
				})
			},
			navfun(type){
				this.navac =  type;
				this.page = 1;
				this.datas = [];
				this.initData();
			}
		},
		onPullDownRefresh() {
			this.page = 1;
			this.datas = [];
			this.initData();
			uni.stopPullDownRefresh();
		},
		onReachBottom() {
			this.page++;
			this.initData()
		},
	};
</script>

<style scoped lang="scss">
	page{
		background: #F7F7F7;
	}
	.tagnav{
		position:sticky;
		top: 0;
		width: 100%;
		padding:15rpx 0 20rpx;
		background: #fff;
		.tagnavmain{
			width:50%;
			display: flex;
			justify-content: space-between;
			.naveach {
				position: relative;
				color: #999999;
				font-size:30rpx;
				text-align: center;
				font-weight: 600;
				.naveachx {
					position: absolute;
					bottom: -10rpx;
					left: 50%;
					background: #fff;
					width: 50rpx;
					margin-left: -25rpx;
					height: 6rpx;
					border-radius: 100rpx;
					transition: background .5s;
				}
			}
			.navactive {
				color:#333333;
				
				.naveachx {
					background: #2AB4FF;
				}
			}
		}
	}
	.mx{
		width: 690rpx;
		margin-top: 20rpx;
		background: #fff;
		.mxeach{
			width: 650rpx;
			padding: 20rpx;
			justify-content: space-between;
			border-radius: 20rpx;
			.mxeachl{
				width: 70%;
				line-height: 50rpx;
				.mxeachlt{
					font-size:30rpx;
				}
				.mxeachltime{
					font-size: 24rpx;
					color: #9E9E9E;
					line-height:50rpx;
				}
			}
			.mxeachr{
				position: relative;
				color: #333333;
				line-height:70rpx;
				text-align: right;
				.withstatus{
					position:absolute;
					bottom:-14rpx;
					font-size: 24rpx;
				}
			}
		}
	}
</style>